package com.example.blades.mydialogprogress;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;

public class DialogProgress extends AppCompatActivity {
    private ProgressBar firstBar=null;
    private ProgressBar secBar=null;
    private Button mybtn=null;
    private int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_progress);

        firstBar=(ProgressBar) findViewById(R.id.firstBar);
        secBar=(ProgressBar) findViewById(R.id.secBar);
        mybtn=(Button) findViewById(R.id.mybtn);
        mybtn.setOnClickListener(new ButtonListener());
    }

    class ButtonListener implements OnClickListener
    {
        @Override
        public void onClick(View v) {

            if(i==0)
            {
                firstBar.setVisibility(View.VISIBLE);
                secBar.setVisibility(View.VISIBLE);
                firstBar.setMax(150);
            }
            else if(i<firstBar.getMax())
            {
                firstBar.setProgress(i);
                firstBar.setSecondaryProgress(i+10);
            }
            else
            {
                firstBar.setVisibility(View.GONE);
                secBar.setVisibility(View.GONE);
            }
            i=i+10;
        }
    }
}
